from openpyxl import load_workbook

wb = load_workbook('test2.xlsx')
# 获取工作表
# ws1 = wb.active
# ws1['A1'] = 'hello'

# 创建工作表
# ws2 = wb.create_sheet('new sheet')
# ws2 = wb.active
# ws2['A1'] = 'hello'

# 通过sheet名称获取工作表
# ws3 = wb['new sheet']
# ws3['A2'] = 'I am very happy'

ws4 = wb.get_sheet_by_name('new sheet')
ws4['A3'] = 'very happy'

wb.save('test2.xlsx')
